<?php 
$Auth = Auth::getAuth();
$show_all = $Auth->level > 5;
?><h2>Grading result.</h2>
<table class="task-table">
<tr><th>ID</th><th>Name</th><th>Task</th><th>Result</th><th>Score</th><th>Time</th></tr>
<?php foreach($data as $s):?>
<?php $show_this = $s['uid'] == $Auth->id || $show_all; ?>
<tr<?php if ($show_this && $s['status'] == PASSED) echo ' class="passed"'?>>
<td><?php if($show_this):?><a href="<?php WEBROOT() ?>/submissions/view/<?php echo $s['sid']?>" title="View detail">#<?php echo $s['sid']?></a><?php else:?>#<?php echo $s['sid']?><?php endif?></td>
<td><?php echo $s['school']?></td>
<td><?php if($show_this):?><a href="<?php WEBROOT() ?>/tasks/view/<?php echo $s['task']?>" title="View task"><?php echo $s['task']?></a><?php else:?>?<?php endif?></td>
<td class="task-result">
<?php 
if ($show_this)
switch($s['status']) {
	case IN_QUEUE: echo 'in queue'; break;
	case COMPILING: echo 'compiling...'; break;
	case GRADING: echo 'grading...'; break;
	case COMPILE_ERROR: echo 'compilation error'; break;
	case GRADER_ERROR: echo 'grader error'; break;
	case FAILED:
	case PASSED: echo $s['result']; break;
}
else echo '?';
?>
</td>
<td><?php if ($show_this) printf("%.0f", $s['score']*100); else echo '?'?></td>
<td><?php if ($show_this) printf("%.2f", $s['usage']); else echo '?'?></td>
<td>&nbsp;</td>
</tr>
<?php endforeach?>
</table>
